package me.yxy.mobanddd.components;

import org.springframework.context.ApplicationContext;

/**
 * Spring ApplicationContext代理工具类，用于获取需要的单例组件
 */
public class AppContext {

    private static ApplicationContext context;

    static void setContext(ApplicationContext context) {
        AppContext.context = context;
    }

    public static Object bean(String name){
        return context.getBean(name);
    }

    public static <T> T bean(Class<T> clz){
        return context.getBean(clz);
    }

    public static EventMachine eventMachine(){
        return bean(EventMachine.class);
    }

}
